﻿Imports System.Collections.Generic
Public Class NhanVienDAO
    'phuong thuc lay danh sach dua vao ma mon

    Public Shared Function laydanhsachkhuvuc(ByVal manv As String) As List(Of CNhanVien)
        Dim kq As List(Of CNhanVien) = New List(Of CNhanVien)
        Dim str As String = String.Format("SELECT * from NhanVien where MaKV='{0}' ", manv)
        Dim dt As DataTable = CKetNoi.ExecQuery(str)
        For Each i As DataRow In dt.Rows
            Dim nv As New CNhanVien
            nv.MaNV = i("MaNV")
            nv.HoTen = i("HoTen")
            nv.DiaChi = i("DiaChi")
            nv.DT = i("DT")
            nv.Ngayvaolam = i("Ngayvaolam")
            nv.Songaylam = i("Songaylam")
            nv.Luongcanban = i("Luongcanban")
            nv.Phai = i("Phai")
            nv.Ngaysinh = i("Ngaysinh")
            nv.Ca = i("Ca")
            kq.Add(nv)
        Next
        Return kq
    End Function
    Public Shared Function Insert(ByVal b As CNhanVien) As Integer
        Dim sql As String = String.Format("INSERT INTO NhanVien(MaNV,HoTen,DiaChi,DT,Ngayvaolam,Songaylam,Luongcanban,Phai,Ngaysinh,Ca) VALUES('{0}','{1}',{2},'{3}',{4},{5},{6},'{7}',{8},'{9}')", b.MaNV, b.HoTen, b.DiaChi, b.DT, b.Ngayvaolam, b.Songaylam, b.Luongcanban, b.Phai, b.Ngaysinh, b.Ca)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Delete(ByVal manv As String) As Integer
        Dim sql As String = String.Format("Delete from NhanVien where MaNV='{0}'", manv)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Update(ByVal b As CNhanVien) As Integer
        Dim sql As String = String.Format("Update NhanVien set HoTen='{0}',DiaChi='{1}',DT='{2}',Ngayvaolam={3},Songaylam={4},Luongcanban={5},Phai='{6}',Ngaysinh={7},Ca='{8}'", b.HoTen, b.DiaChi, b.DT, b.Ngayvaolam, b.Songaylam, b.Luongcanban, b.Phai, b.Ngaysinh, b.Ca)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
End Class
